<?php

$link  = mysql_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpassword'], true);
mysql_select_db($_POST['dbname'] ,$link);

$config_query = 'DROP TABLE IF EXISTS `'.$_POST['dbname'].'`.`config`;
CREATE TABLE  `'.$_POST['dbname'].'`.`config` (
  `config_id` int(10) unsigned NOT NULL auto_increment,
  `config_name` varchar(45) NOT NULL,
  `config_value` varchar(100) NOT NULL,
  PRIMARY KEY  (`config_id`)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;';

if(mysql_query($config_query, $link))
	Echo 'Tabella Config Creata<br />';

	
$pg_query = 'DROP TABLE IF EXISTS `'.$_POST['dbname'].'`.`pg`;
CREATE TABLE  `'.$_POST['dbname'].'`.`pg` (
  `pgid` int(10) unsigned NOT NULL auto_increment,
  `pgname` varchar(45) NOT NULL,
  `username` varchar(100) NOT NULL,
  `main` int(1) unsigned NOT NULL,
  `mainrole` varchar(45) NOT NULL,
  `secondrole` varchar(45) default NULL,
  `itemvalue` int(10) unsigned default NULL,
  `gamevalue` int(10) unsigned default NULL,
  `presencevalue` int(10) unsigned default NULL,
  `class` varchar(45) NOT NULL,
  PRIMARY KEY  (`pgid`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;';

if(mysql_query($pg_query, $link))
	Echo 'Tabella PG Creata<br />';

$istance_query = 'DROP TABLE IF EXISTS `'.$_POST['dbname'].'`.`istance`;
CREATE TABLE  `'.$_POST['dbname'].'`.`istance` (
  `istanceid` int(10) unsigned NOT NULL auto_increment,
  `istancename` varchar(100) NOT NULL,
  `istancemaxpg` int(10) unsigned NOT NULL,
  `istancemaxtank` int(10) unsigned NOT NULL,
  `istancemaxdps` int(10) unsigned NOT NULL,
  `istancemaxhealer` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`istanceid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;';

if(mysql_query($istance_query, $link))
	Echo 'Tabella Istance Creata<br />';
	
$user_query ='DROP TABLE IF EXISTS `'.$_POST['dbname'].'`.`user`;
CREATE TABLE  `'.$_POST['dbname'].'`.`user` (
  `userid` int(10) unsigned NOT NULL auto_increment,
  `username` varchar(45) NOT NULL,
  `userpassword` varchar(45) NOT NULL,
  `rankid` int(10) unsigned NOT NULL,
  `gm` int(10) unsigned NOT NULL,
  `officer` int(10) unsigned NOT NULL,
  `classleader` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`userid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;';
	
if(mysql_query($user_query, $link))
	Echo 'Tabella Utenti Creata<br />';
	
$raid_query = 'DROP TABLE IF EXISTS `'.$_POST['dbname'].'`.`raid`;
CREATE TABLE  `'.$_POST['dbname'].'`.`raid` (
  `raidid` int(10) unsigned NOT NULL auto_increment,
  `istanceid` int(10) unsigned NOT NULL,
  `raidtext` varchar(200) NOT NULL,
  `startdate` int(10) unsigned NOT NULL,
  `enddate` int(10) unsigned NOT NULL,
  `duedate` int(10) unsigned NOT NULL,
  `comment` longtext,
  `rankmin` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`raidid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;';

if(mysql_query($raid_query, $link))
	Echo 'Tabella Raid Creata<br />';

?>